/**
 * 
 */
lang = {'fail':'系统错误','suc':'操作成功'};
var tip = function(){},T;
window.onload = function(){
	msgDiv=document.createElement('div');
	msgDiv.id='msgDiv';
	msgDiv.style.display='none';
	document.body.appendChild(msgDiv);
	bgDiv=document.createElement('div');
	bgDiv.id='bgDiv';
	bgDiv.style.display='none';
	document.body.appendChild(bgDiv);
	if (typeof _winload!= 'undefined'){
		_winload();
	};
	T=new tip();
};
tip.prototype.close = function(){msgDiv.style.display='none';bgDiv.style.display='none';};
tip.prototype.runfirst=function(){bgDiv.style.width=document.documentElement.clientWidth+"px";bgDiv.style.height=document.documentElement.scrollTop+document.documentElement.clientHeight+'px';msgDiv.style.left=(document.documentElement.scrollWidth/2-msgDiv.clientWidth/2)+'px';msgDiv.style.top=(document.documentElement.scrollTop+(document.documentElement.clientHeight/2-msgDiv.clientHeight/2))/2+'px';bgDiv.style.display='block';try{$('wait').style.cursor='pointer';$('wait').id='';}catch(e){}};
tip.prototype.login = function(){ny.ajax.callFile('/public/inc/tip_login.html',function(de){msgDiv.innerHTML=de.replace('{backurl}',encodeURI(document.location.pathname+document.location.search));msgDiv.style.display='block';T.runfirst();})};
tip.prototype.needlogin = function(){ny.ajax.callFile('/public/inc/tip_needlogin.html',function(de){msgDiv.innerHTML=de.replace('{backurl}',encodeURI(document.location.pathname+document.location.search));msgDiv.style.display='block';T.runfirst();})}
tip.prototype.normal = function(txt){ny.ajax.callFile('/public/inc/tip_normal.html',function(de){msgDiv.innerHTML=de.replace('{$notice}',txt);msgDiv.style.display='block';T.runfirst();})};
tip.prototype.addtip = function(id, msg, style) {
	if (!style) {
		style = 'tip';
	}
	if (!msg) {
		msg = lang['fail'];
	}
	if (!$('.' + style).html()) {
		$('body').append("<div class='" + style + "'></div>");
		$('div.' + style).append("<div class='" + style + "_head'></div>");
		$('div.' + style).append("<div class='" + style + "_content'></div>");
	}
	var obj = $(id);
	var left = obj.offset().left;
	var height = obj.height() + 10;
	var top = obj.offset().top;
	var tip = $('div.' + style);
	tip.offset({
		left : left,
		top : top + height
	});
	$('div.' + style + '_content').html(msg);
	tip.show();
	setTimeout(function() {
		var tip = $('div.' + style);
		tip.fadeOut(1000, function() {
			tip.remove();
		});
	}, 2000);
};
tip.prototype.addTop = function(msg){
	style = 'tip';
	if (!msg) {
		msg = lang['fail'];
	}
	if (!$('.' + style).html()) {
		$('body').append("<div class='" + style + "'></div>");
		$('div.' + style).append("<div class='" + style + "_head'></div>");
		$('div.' + style).append("<div class='" + style + "_content'></div>");
	}
	var left = $('body').width()/2;
	var height = 20;
	var top = $('body').height()/2;
	var tip = $('div.' + style);
	tip.offset({
		left : left,
		top : top + height
	});
	$('div.' + style + '_content').html(msg);
	tip.show();
	setTimeout(function() {
		var tip = $('div.' + style);
		tip.fadeOut(1000, function() {
			tip.remove();
		});
	}, 2000);
};
tip.prototype.confirm = function(msg){return confirm(msg)};
tip.prototype.load = function(url){ny.ajax.callFile(url,function(de){msgDiv.innerHTML=de;msgDiv.style.display='block';T.runfirst();})}
tip.prototype.setCookie = function(name, value, seconds, path, domain){return ny.cookie.set(name, value, seconds, path, domain)}
tip.prototype.getCookie = function(name){return ny.cookie.get(name)}
tip.prototype.delCookie = function(name){return ny.cookie.del(name)}
tip.prototype.serialize = function(formid){return $('#'+formid).serialize()} //formid为表单ID
tip.prototype.deserialize = function(a){
	var a = a.split('&')
	var b=[];
	for(var i=0;i<a.length;i++){
		var temp = a[i].split('=')
		b[temp[0]] = decodeURIComponent(temp[1])
	}
	return b
}